home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1986 September & October
/
rerun-1986-09-10.d64
/
find the word
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
4KB
|
146 lines
2 goto10
5 dime$(20,22),d$(20),zx(20),zy(20),qa(8),qb(8),tw(20),h$(20,22):return
10 rem jerry caron
12 rem berkley st.
14 rem berkley,ma.
20 rem initialize
30 print"[147] find a word"
40 print"are you using":print"a vic 20[146] or a 64[146]"
42 input"enter 20 or 64 64[157][157][157][157]";ma:ifma<>20and ma<>64then42
44 input"load a previous puzzle (y or n)";lp$
45 iflp$<>"y"andlp$<>"n"thenprint"[145][145][145][145]":goto44
46 iflp$="y"thengosub1000
55 ifma=20thenpoke36879,8
56 print:print
57 input" puzzle size (10-20) 20[157][157][157][157]";ms
58 ifms<10orms>20then57
59 gosub950
60 print"[147] setting up please wait..."
70 ifsw$<>"y"thengosub5
80 fori=1toms:forj=1toms:e$(i,j)="":next:next
90 restore:forj=1toop:fori=1to8 : readqa(i),qb(i):next:next
100 data.,-1,1,-1,1,.,1,1,.,1,-1,1,-1,.,-1,-1,.,1,1,-1,1,1,1,.,.,1,1,-1,1,1,1,.
103 data.,1,1,.,.,-1,-1,.,.,1,1,.,.,-1,-1,.,.,1,1,.,.,1,1,.,.,1,1,.,.,1,1,.
108 ifsw$="y"then310
110 fori=1toms:d$(i)="":zx(i)=0:zy(i)=0:next
200 rem input words
205 iflp$="y"then310
210 print"[147]how many words (max ";ms-op+1;")"
220 input nd$
230 print:nw=val(nd$):ifnw<1ornw>ms-op+1then210
240 print"[147] now type in the words"
250 print"each must be between 3 and ";int(.76*ms);" letters"
260 fori=1tonw
270 printi"[157]) ";
280 input"[157]";d$(i)
290 if len(d$(i))<3 or len(d$(i))>int(.76*ms)thenprintchr$(13)"[145][145][145]":goto270
300 print:next
310 open4,4
315 print#4,spc(ms-5);chr$(14)+"find the words"+chr$(15):print#4:print#4
316 iflp$="y"thenprint#4,"puzzle name : ";np$:print#4
317 forr=1to3*ms+4:print#4,"*";:nextr:print#4:print#4
320 fori=1tonw
330 print#4,d$(i);spc(ms-len(d$(i)));:ifi=4ori=8ori=12ori=16thenprint#4,:
340 next
350 print#4,:print#4,:forr=1to3*ms+4 :print#4,"*";:nextr:print#4,:print#4,"*";
360 print#4," ";spc(3*ms+1);"*"
370 close4:iflp$="y"then700
380 ifep$="y"then700
400 rem place
410 print"[147] making grid "
420 print" please wait"
430 pw=0:forab=1tonw:pw=pw+1
440 zx(pw)=int(ms*rnd(1)+1)
450 zy(pw)=int(ms*rnd(1)+1)
460 dr=int(8*rnd(1)+1):tw(pw)=dr
470 cx=zx(pw)+len(d$(pw))*qa(dr):cy=zy(pw)+len(d$(pw))*qb(dr)
480 ifcx<1orcx>msorcy<1orcy>msthen440
490 f=0:forck=0tolen(d$(pw))-1
500 z1$=mid$(d$(pw),ck+1,1):z2$=e$(zx(pw)+ck*qa(dr),zy(pw)+ck*qb(dr))
510 ifz2$<>""andz1$<>z2$thenf=1
520 next:iff=1then440
530 forck=0tolen( d$(pw))-1
540 z1$=mid$(d$(pw),ck+1,1):e$(zx(pw)+ck*qa(dr),zy(pw)+ck*qb(dr))=z1$
550 next
560 next ab
600 rem print search matrix
610 print"[147]"
620 print"":fory=1toms:forx=1toms
621 ifms<20anddx=1thenprint
622 h$(x,y)=e$(x,y):ife$(x,y)=""thenh$(x,y)="-"
625 ife$(x,y)=""thene$(x,y)=mid$(d$(nw*rnd(1)+1),3*rnd(1)+1,1)
640 ifma=64thenprinte$(x,y);" ";:goto660
650 ifma=20thenprinte$(x,y);
660 next
670 ifma=20thenprint
690 c=0:next
700 open4,4
710 fory=1toms:print#4,"* ";:forx=1toms
720 print#4,e$(x,y);" ";
730 next:print#4,"*":print#4,"*";spc(3*ms+2);"*":next
740 forr=1to3*ms+4:print#4,"*";:nextr:print#4,:print#4:close4
800 print"[147]":lp$="":gs$="":sp$="":s$="" :ep$="":sw$=""
805 input"want the answers y or n y[157][157][157]";gs$
807 ifgs$="y"thenprint" don't peek!":gosub900
808 print" save the puzzle (y or n)";
809 inputsp$:ifsp$="y"theninput" name of puzzle";np$:np$=np$+".ws":gosub1100
810 input"y[146]es to run again y[157][157][157]";s$:ifs$<>"y"thenend
820 input"want exact same puzzle (y or n)";ep$:ifep$="y"then310
830 input"want the same words (y or n)";sw$:ifsw$="y" then1200
840 ifep$="n"thenclr:goto44
860 print"[147] program over":end
900 open4,4
903 fori=1to10-2*ms:print#4:next
910 fory=1toms :forx=1toms
911 print#4,h$(x,y);" ";
920 next:print#4:next
930 print#4:close4:return
940 rem direction option menu
950 print"[147] word direction options [146]"
960 print" 1. every direction"
965 print" 2. no reversed words"
970 print" 3. no diagonal words"
975 print" 4. no diagonal or reversed words"
980 input"choose option[146] (1-4) 1[157][157][157]";op
982 ifop<1orop>4thenprint"[145][145][145]":goto980
985 return
1000 rem load routine*****************
1005 open15,8,15:print#15,"i0"
1010 print"name of puzzle";:inputnp$:np$=np$+".ws"
1020 open1,8,8,np$+",s,r"
1025 input#15,e,e$,e1,e2
1027 ifethenprint"program aborted *error* ";e$:close1:close15:end
1030 input#1,ms
1031 input#1,nw
1032 input#1,op
1035 gosub5
1040 fory=1toms:forx=1toms
1050 input#1,e$(x,y)
1060 next:next
1065 fori=1tonw:input#1,d$(i):next
1066 fory=1toms:forx=1toms
1067 input#1,h$(x,y)
1068 next:next
1070 close1:close15
1080 goto310
1100 rem save routine*****************
1101 print"saving puzzle"
1103 open15,8,15:print#15,"i0"
1110 open1,8,8,"0:"+np$+",s,w"
1115 input#15,e,e$,e1,e2:ifethenprint"prg. aborted *error* ";e$:close15:end
1120 print#1,ms
1121 print#1,nw
1125 print#1,op
1130 fory=1toms:forx=1toms
1140 print#1,e$(x,y)
1150 next:next
1155 fori=1tonw:print#1,d$(i):next
1158 fory=1toms:forx=1toms
1159 print#1,h$(x,y)
1160 next:next
1165 close1:close15
1170 return
1200 print"please wait":forx=1to20:fory=1to22:e$(x,y)="":h$(x,y)="":next:next
1210 forx=1to20:zx(x)=0:zy(x)=0:tw(x)=0:next:forx=1to8:qa(x)=0:qb(x)=0:next
1220 goto59